package com.ruoyi.data.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.data.domain.DataScore;
import com.ruoyi.data.domain.DataScoreExchange;
import com.ruoyi.data.mapper.DataScoreMapper;
import com.ruoyi.data.service.IDataScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 积分记录Service业务层处理
 *
 * @author zzp
 * @date 2022-09-30
 */
@Service
public class DataScoreServiceImpl implements IDataScoreService {
    @Autowired
    private DataScoreMapper dataScoreMapper;

    /**
     * 查询积分记录
     *
     * @param id 积分记录主键
     * @return 积分记录
     */
    @Override
    public DataScore selectDataScoreById(Long id) {
        return dataScoreMapper.selectDataScoreById(id);
    }

    /**
     * 查询积分记录列表
     *
     * @param dataScore 积分记录
     * @return 积分记录
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<DataScore> selectDataScoreList(DataScore dataScore) {
        return dataScoreMapper.selectDataScoreList(dataScore);
    }

    /**
     * 新增积分记录
     *
     * @param dataScore 积分记录
     * @return 结果
     */
    @Override
    public int insertDataScore(DataScore dataScore) {
        dataScore.setCreateTime(DateUtils.getNowDate());
        return dataScoreMapper.insertDataScore(dataScore);
    }

    /**
     * 修改积分记录
     *
     * @param dataScore 积分记录
     * @return 结果
     */
    @Override
    public int updateDataScore(DataScore dataScore) {
        dataScore.setUpdateTime(DateUtils.getNowDate());
        return dataScoreMapper.updateDataScore(dataScore);
    }

    /**
     * 批量删除积分记录
     *
     * @param ids 需要删除的积分记录主键
     * @return 结果
     */
    @Override
    public int deleteDataScoreByIds(Long[] ids) {
        return dataScoreMapper.deleteDataScoreByIds(ids);
    }

    /**
     * 删除积分记录信息
     *
     * @param id 积分记录主键
     * @return 结果
     */
    @Override
    public int deleteDataScoreById(Long id) {
        return dataScoreMapper.deleteDataScoreById(id);
    }

    @Override
    public List<DataScore> selectDataScoreListByUserId(Long userId, String scoreType) {
        return dataScoreMapper.selectDataScoreListByUserId(userId, scoreType);
    }

    /**
     * 兑换积分列表
     *
     * @param dataScore
     * @return
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<DataScore> selectDataScoreExchangeList(DataScore dataScore) {
        return dataScoreMapper.selectDataScoreExchangeList(dataScore);
    }

    /**
     * 批量插入
     *
     * @param exchangeList
     * @return
     */
    @Override
    public int batchInsert(List<DataScore> exchangeList) {
        return dataScoreMapper.batchInsert(exchangeList);
    }

    @Override
    @DataScope(deptAlias = "d")
    public List<DataScoreExchange> selectDataScoreExchangeListExport(DataScore dataScore) {
        return dataScoreMapper.selectDataScoreExchangeListExport(dataScore);
    }
}
